<template>
    <div>
      <h2>朋友1</h2>
      <p>姓名：{{friendName}}</p>
      <p>年龄：{{age}}</p>
      <p>性别：{{gender}}</p>
      <button @click="sendName">将名字传递出去</button>
    </div>
</template>

<script>
export default {
  name:"Friends",
  data(){
    return {
      friendName:"小明",
      age:21,
      gender:'男'
    }
  },
  methods:{
    sendName(){
      this.$bus.$emit('showMsg',this.friendName)
    }
  },
  mounted(){
    this.$bus.$on('ShowstudentName',data=>{
      alert(data)
    })
  }
}
</script>

<style>

</style>